﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BLGPS
{
    public class Configuration
    {
        #region Singleton
        private static Configuration s_Current;

        public static Configuration Current
        {
            get
            {
                if (s_Current == null)
                {
                    s_Current = Load();
                    
                    if (s_Current == null)//si sigue siendo null
                    {
                        s_Current = new Configuration();                        
                    }
                }
                return s_Current;
            }
        }
        #endregion

        public string ConnectionString { get; set; }
        public string  PathDB { get; set; }       
                

        public Configuration()
        {
            PathDB = @"I:\Martin\GPS\GPSTraking\WebSite\App_Data\Database.mdf";
            //ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename="+PathDB+";Integrated Security=True;User Instance=True";
            ConnectionString = @"Data Source=CHATO-NBK\SQLSERVER2008;Initial Catalog=AUFSAT;User ID=sa;Password=sasa";
        }

        public static Configuration Load()
        {
            return Serializer.Open<Configuration>(AppDomain.CurrentDomain.BaseDirectory + "Config.xml");
        }
               
        public void Save()
        {
            Serializer.Save(this, AppDomain.CurrentDomain.BaseDirectory + "Config.xml");
        }
    }
}
